<template>
  <ul class="todo-list">
    <!-- completed: 完成的类名 -->
    <li
      v-for="obj in list"
      :key="obj.id"
      :class="{ completed: obj.isDone }"
      @click="$store.commit('main/setIsDone', obj.id)"
    >
      <div class="view">
        <input
          class="toggle"
          type="checkbox"
          v-model="obj.isDone"
          :id="obj.id"
        />
        <label :for="obj.id" @click="$store.commit('main/setIsDone', obj.id)">{{
          obj.name
        }}</label>
        <button
          class="destroy"
          @click="$store.commit('main/delList', obj.id)"
        ></button>
      </div>
    </li>
  </ul>
</template>

<script>
export default {
  name: 'TodoMain',

  methods: {},

  computed: {
    list() {
      return this.$store.getters.rlist
    }
  }
}
</script>